cmake_minimum_required( VERSION 3.20.0 )

project( ffc-cppunit-library C CXX ) # [JSD] change this name in the copy (!)


JSD_SHOW_PROJECT_HEADER()


include( ffc-cppunit-library-set-compiler-settings ) # [JSD] change this name in the copy (!)


# JSD_FFC_FORK_SOURCE_ROOT_PATH
##  this project headers and sources enumeration section
set( project_adhoc_common_directory ${JSD_FFC_ADHOC_PATH}/common )
set( project_adhoc_common_headers ${project_adhoc_common_directory}/*.h* )
set( project_adhoc_common_sources ${project_adhoc_common_directory}/*.c* )

if( UNIX )
	set( project_adhoc_platform_directory ${JSD_FFC_ADHOC_PATH}/linux )
elseif ( WIN32 )
	set( project_adhoc_platform_directory ${JSD_FFC_ADHOC_PATH}/windows )
endif()

set( project_adhoc_platform_headers ${project_adhoc_platform_directory}/*.h* )
set( project_adhoc_platform_sources ${project_adhoc_platform_directory}/*.c* )

set( project_headers_directory ${JSD_FFC_FORK_SOURCE_ROOT_PATH}/include )
set( project_headers_headers ${project_headers_directory}/*.h* )
set( project_headers_sources ${project_headers_directory}/*.c* )
set( project_source_directory ${JSD_FFC_FORK_SOURCE_ROOT_PATH}/src )
set( project_sources_headers ${project_source_directory}/*.h* )
set( project_sources_sources ${project_source_directory}/*.c* )

file( GLOB_RECURSE project_headers_and_sources
	${project_adhoc_common_headers}
	${project_adhoc_common_sources}
	${project_adhoc_platform_headers}
	${project_adhoc_platform_sources}
	${project_headers_headers}
	${project_headers_sources}
	${project_sources_headers}
	${project_sources_sources}
)

set( JSD_THIS_PROJECT_FILES_TO_REMOVE
	"DllMain"
	"msvc6"
	"DllPlugInTester"
	"plugin"
	"PlugIn"
	"Dynamic"
	"config-bcb5"
	"config-evc4"
	"config-mac"
	"SelectDllLoader"
)

if( UNIX )
	list( APPEND JSD_THIS_PROJECT_FILES_TO_REMOVE "" )
elseif ( WIN32 )
	list( APPEND JSD_THIS_PROJECT_FILES_TO_REMOVE "" )
endif()

JSD_REMOVE_FILES_FROM_THE_LIST( project_headers_and_sources JSD_THIS_PROJECT_FILES_TO_REMOVE )

add_library( ${PROJECT_NAME} ${project_headers_and_sources} )
## ~this project headers and sources enumeration section


##  project and target definition section
set_target_properties(
	${PROJECT_NAME}
		PROPERTIES
			POSITION_INDEPENDENT_CODE ON # required to be able to be linked into shared libraries.
			VERSION 0.1.0
			SOVERSION 0.1
#			DEFINE_SYMBOL JSD_${PROJECT_NAME}_SHARED_INTERFACE_INTERNAL
)

set( project_public_definitions
	CPPUNIT_DLL
)
JSD_REPLACE_DASH_WITH_UNDERSCORE_INPLACE( project_public_definitions )
JSD_TO_UPPER_INPLACE( project_public_definitions )

set( project_private_definitions
	CPPUNIT_BUILD_DLL
)
JSD_REPLACE_DASH_WITH_UNDERSCORE_INPLACE( project_private_definitions )
JSD_TO_UPPER_INPLACE( project_private_definitions )

target_compile_definitions(
	${PROJECT_NAME}
		PUBLIC
		    ${project_public_definitions}
		PRIVATE
			${project_private_definitions}
)

if( UNIX )
	set( THIS_PROJECT_DEPENDENCY_LIBRARIES
		dl )
elseif( WIN32 )
	set( THIS_PROJECT_DEPENDENCY_LIBRARIES
	    )
endif()

target_link_libraries(
	${PROJECT_NAME}
		PUBLIC
		    jsd-platform
			${THIS_PROJECT_DEPENDENCY_LIBRARIES}
		PRIVATE
)
## ~project and target definition section


##  target include directories
target_include_directories(
	${PROJECT_NAME}
		PUBLIC
		    ${project_adhoc_common_directory}
			${project_adhoc_platform_directory}
			${project_headers_directory}
		PRIVATE
			${project_source_directory}

)
## ~target include directories


JSD_SHOW_PROJECT_FOOTER()
